﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
//
using PerceptiveMCAPI;
using PerceptiveMCAPI.Types;
//

namespace PerceptiveMCAPI_Test
{
   public partial class show_campaignEmailStatsAIMAll : System.Web.UI.UserControl
   {
      public void Display( campaignEmailStatsAIMAllOutput output )
      {
         this.Visible = true;
         lblCount.Text = output.result.Count.ToString();

         gvEmailStatsAIMAll.DataSource = output.result;
         gvEmailStatsAIMAll.DataBind();
      }
      //

      protected string FormatStats( object statsIn )
      {
         List<campaignEmailStatsAIMResults> emailStats = statsIn as List<campaignEmailStatsAIMResults>;
         if ( emailStats.Count > 0 )
         {
            StringBuilder sb = new StringBuilder();
            foreach ( campaignEmailStatsAIMResults stats in emailStats )
            {
               string ts = stats.timestamp.ToString( "yyyy-MM-dd HH:mm:ss" );
               sb.AppendFormat( "{0} at {1} from {2} &nbsp; {3}<br />", stats.action, ts, stats.ip, stats.url );
            }
            return sb.ToString( 0, sb.Length - 6 );
         }
         else
            return "No actions found";
      }
   }
}